package com.android.antelopeapp.common;

import android.graphics.Bitmap;

import java.util.HashMap;

/**
 * Created by phk on 2015/1/3.
 * 将一些全局需要用到的资源保存在内存中
 * 此类为单例
 */
public class GlobalResource {
    static private GlobalResource self = new GlobalResource();
    public static final String TAGED_IMG = "taged_img";
    /**
     * 用于缓存图片
     */
    HashMap<String,Bitmap> imgMap = new HashMap<>();

    private GlobalResource() {
    }

    public static GlobalResource getInstance() {
        return self;
    }

    public Bitmap getmBitmap(String key) {
        return imgMap.get(key);
    }

    public void cacheBitmap(String key,Bitmap bitmap) {
        imgMap.put(key,bitmap);
    }

    public void release(){
        imgMap.clear();
    }

    public void releaseBitmap(String key) {
        imgMap.remove(key);
    }
}
